<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!--<script src="jquery-3.2.1.min.js"></script>-->
    <title>小红的故事</title>
</head>

<body>

</body>
<script>
    //最大差值
    var arr = [1, 950, 20, 30, 100, 1000]
    var czValue = function(arr) {
        var oldbig = 0;
        var big = 0;
        for (var i = 0; i < arr.length - 1; i++) {
            oldbig = Math.abs(arr[i] - arr[i + 1]);
            if (oldbig > big) {
                big = oldbig;
            }
        }
        console.log(big);
    }
    czValue(arr);

    //随机字母
    var num = 8;
    var randomly = function(num) {
        var letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
        var result = "";
        for (var i = 0; i < num; i++) {
            var a = Math.floor(Math.random() * 26);
            result += letters[a]
        }
        console.log(result);
    }
    randomly(num);

    //小红的故事
    var people = function(string) {
        return new Promise(
            function() {
                console.log("你好，我是" + string + "!");
            }
        )
    };
    var eat = function(stringeat) {
        console.log("我在吃" + stringeat)
    };

    var sleep = function(num) {
        setTimeout(function() {
            console.log(num + "秒后");
        }, num + "000")
    };
    var sleepFirst = function(num) {
        setTimeout(function() {
            console.log("等待" + num + "秒后，输出");
        }, num + "000")
    };
    // var people = new people("小红");
    people("小红");
    sleep(2);
    sleepFirst(2);
    eat("早餐");
</script>

</html>

</html>